import time

from selenium.webdriver.common.by import By
from Base.Base import Base
class Page(Base):
    login_loc=(By.XPATH,'/html/body/div[2]/div/div[1]/div/a[1]')
    def login_click(self):
        self.click(self.login_loc)
    # 断言1 免费注册
    dy1_loc=(By.XPATH,'/html/body/div/form/div/div/div/div/div[1]/div[1]/a[1]')
    def dy1(self):
        return self.get_text(self.dy1_loc)
    name_loc=(By.ID,'userName')
    def name(self):
        self.send_keys(self.name_loc,'17800382573')
    pwd_loc = (By.ID, 'password')
    def pwd(self):
        self.send_keys(self.pwd_loc, '123456Aa')
    dl_loc=(By.ID,'save')
    def dl(self):
        self.click(self.dl_loc)
    # 断言2 jxw267546976
    dy2_loc=(By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span')
    def dy2(self):
        return self.get_text(self.dy2_loc)
    search_loc=(By.XPATH,'//*[@id="wd"]')
    def search(self):
        self.send_keys(self.search_loc,'二锅头')
    sou_loc=(By.ID,'wd')
    def sou(self):
        self.click(self.sou_loc)
    # 断言3 全部商品分类
    dy3_loc=(By.XPATH,'/html/body/div[4]/div/div/h2')
    def dy3(self):
        return self.get_text(self.dy3_loc)
    def Enter(self):
        self.enters(self.sou_loc)
    # sp_lod=(By.CSS_SELECTOR,'body > div.srpWrap > div > div.main-srp > div:nth-child(7) > ul > li:nth-child(1) > div.content.clearfix > div.collect_box > a > img')
    # def sp(self):
    #     self.click(self.sp_lod)

    add_loc=(By.XPATH,'//*[@id="addcart_61920"]/a')
    def addcar(self):
        self.click(self.add_loc)
    car_loc=(By.XPATH,'/html/body/div[7]/div/div/p[2]/a[1]')
    # 断言4 该商品已成功放入购物车
    dy4_loc = (By.XPATH, '/html/body/div[7]/div/div/h6')
    def dy4(self):
        return self.get_text(self.dy4_loc)
    def look_car(self):
        self.click(self.car_loc)
    # 断言5 我的购物车
    dy5_loc=(By.XPATH,'//*[@id="cart_container"]/div[2]/div[1]/div[1]')
    def dy5(self):
        return self.get_text(self.dy5_loc)
    jie_loc=(By.XPATH,'/html/body/div[3]/div[1]/div[3]/div[3]/a[1]')
    def jiesuan(self):
        self.click(self.jie_loc)
    # 断言6 确认订单信息
    dy6_loc=(By.XPATH,'/html/body/div[3]/div/div[3]/div[1]/h3')
    def dy6(self):
        return self.get_text(self.dy6_loc)
    ti_loc=(By.ID,'submitOrder')
    def tijiao(self):
        self.click(self.ti_loc)
    # 断言7 请你在约定时间内完成支付，逾期订单将被取消！
    dy7_loc=(By.XPATH,'/html/body/div[4]/div/div[1]/ul/li[2]')
    def dy7(self):
        return self.get_text(self.dy7_loc)

    def luoji_login(self):
        self.open_url('https://www.jiuxian.com/')
        self.login_click()
        self.name()
        self.pwd()
        time.sleep(15)
        self.dl()
